package file;

import java.io.File;
/**访问目录的子项*/
public class ListFileDemo {
    public static void main(String[] args) {
        File file=new File(".");//当前目录
        if(file.isDirectory()){
            File[] sub=file.listFiles();
            System.out.println("一共有"+sub.length+"个子项");
            for (File f:sub){
                System.out.println(f.getName());
            }
        }

    }
}
